15. Creating the Lidar Object

Header Text

Creating the Lidar Object

ND313 C1 L1 A12 Create Lidar

Adding Lidar

The first thing you are going to do is create a lidar object. The lidar object is defined by the src/sensors/lidar.h header file which is included at the top of environment.cpp. Also in environment.cpp is the simpleHighway function, which takes a reference argument for the PCL visualizer viewer that was discussed previously.

Exercise Instructions

You will instantiate a pointer to a Lidar object in the simpleHighway function.
You should create the Lidar pointer object on the heap, using the new keyword.
The Lidar constructor takes two arguments: cars and the slope of the ground - these arguments are necessary for modeling ray collisions. The Lidar object should be created with a slope of 0.

Note

The lidar arguments are necessary for modeling ray collisions.
The Lidar object is going to be holding point cloud data which could be very large. By instatinating on the heap, we have more memory to work with than the 2MB on the stack. However, it takes longer to look up objects on the heap, while stack lookup is very fast.

Workspace

This section contains either a workspace (it can be a Jupyter Notebook workspace or an online code editor work space, etc.) and it cannot be automatically downloaded to be generated here. Please access the classroom with your account and manually download the workspace to your local machine. Note that for some courses, Udacity upload the workspace files onto https://github.com/udacity , so you may be able to download them there.

Workspace Information:

  • Default file path:
  • Workspace type: react
  • Opened files (when workspace is loaded): n/a

Solution

ND313 C1 L1 A12 Creating The Lidar Object Solution [LB]